from fastapi import APIRouter
from sqlalchemy.orm import Session

from app.api.deps import DbDependency
from app.crud import brand_service
from app.schemas.brand import BrandBo

router = APIRouter()


@router.get("/list", description="品牌列表")
def list_brands(db: DbDependency):
    return brand_service.brand_list(db)


@router.get("/detail", description="详情")
def detail_brand(brand_id: int, db: DbDependency):
    return brand_service.get_brand(db, brand_id)


@router.post("/add", description="新增")
def create_brand(brand: BrandBo, db: DbDependency):
    return brand_service.brand_save(db, brand)


@router.put("/update", description="修改")
def update_brand(brand: BrandBo, db: DbDependency):
    return brand_service.brand_edit(db, brand)


@router.delete("/{brand_id}", description="删除")
def remove_brand(brand_id: int, db: DbDependency):
    return brand_service.brand_delete(db, brand_id)


@router.get("/choose", description="选择品牌")
def list_brands(db: DbDependency, categoryId: int, ):
    return brand_service.query_brand_by_category_id(db, categoryId)
